package com.xxx.client.android.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Gallery;

import com.xxx.client.android.R;
import com.xxx.client.android.widget.RemoteImageView;

public class SceneSmallAdapter extends SceneAdapter {

	int mIconSize;

	public SceneSmallAdapter(Activity context) {
		super(context);
		mIconSize = (int) context.getResources()
				.getDimension(R.dimen.scene_icon_size);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		RemoteImageView i;

		if (convertView == null) {
			i = new RemoteImageView(mContext);
			i.setScaleType(RemoteImageView.ScaleType.FIT_CENTER);
			i.setLayoutParams(new Gallery.LayoutParams(mIconSize, mIconSize));
		} else {
			i = (RemoteImageView) convertView;
		}

		i.setDefaultImage(R.drawable.default_icon);
		i.setImageUrl(mList.get(position));

		return i;
	}

	/**
	 * Class implementing holder pattern, performance boost
	 */
	static class ViewHolder {
		RemoteImageView image;
	}
}
